Apple, the Apple logo, and Macintosh are registered trademarks of Apple Computer, Inc.
Mac and OpenDoc are trademarks of Apple Computer, Inc.
Changes since DR2
1) Corrected usage of ODStorageUnit::GetStrongStorageUnitRef and GetWeakStorageUnitRef.
2) Fixed parameter passing errors of GetValue and SetValue.
Overview
A Persistent Reference is used in a Storage Unit Value to refer to another Storage Unit in the same Document. This Reference is persistent in the sense that it is preserved across sessions.
References are used in many places in OpenDoc:
1) The Draft has a list of references to the root frames. When a Draft is opened, the root parts can use the frames to construct their windows.
2) Frame has a Persistent Reference to its Part and the Part in turn has a Persistent Reference to its Display and Embedded Frames. Persistent References to Embedded Frames are essential to part embedding.
3) Parts need Persistent References for hierarchical storage.
The following is a (simplified) diagram of what the persistent objects in an OpenDoc Document relate to each other (with arrows being Persistent References):
ODStorageUnitRef
This Persistent Reference in OpenDoc is typed ODStorageUnitRef. ODStorageUnitRef is a 32-bit value. One should never try to inspect or interpret a ODStorageUnitRef. ODStorageUnit and ODStorageUnitView provides a set of methods to manipulate ODStorageUnitRef.
ODStorageUnitRef can only be created from a ODStorageUnit which is focused to a Value or a ODStorageUnitView (is to be focused to a Value). The scope of the ODStorageUnitRef is then limited to the Value from which it is created. It is illegal and dangerous to use ODStorageUnitRef in a different Value. It will almost certainly not refer to the correct Storage Unit rendering the resulting behavior unpredictable.
One can create virtually unlimited number of References in a Storage Unit Value.
If a Persistent Reference is no longer needed, one should remove it from the Value from which it is created. It is crucial to have unnecessary Persistent References removed for efficiency, robustness and effective garbage collection.
ODStorageUnitRef is not recycled. Therefore, all ODStorageUnitRefs from a Value are guaranteed to be unique.
The “referring power” of ODStorageUnitRef are preserved across sessions. One can write out a ODStorageUnitRef in the Value, close and reopen the Container and use the ODStorageUnitRef in that Value to find the referred Storage Unit.
Strong and Weak ODStorageUnitRef
There are two kinds of ODStorageUnitRef -- strong and weak. Their difference is important when a Clone operation is performed (using ODDraft::BeginClone and ODDraft::EndClone). In a Clone operation, all the Storage Units referenced by a Strong ODStorageUnitRef are copied. Consider the following example,